<template>
  <TreeList
    ref="treeList"
    :operationList="operationList"
    :showTree="false"
    :columns="columns"
    :treeUrl="treeUrl"
    :treeData="treeData"
    :treeMap="treeMap"
    :listUrl="listUrl"
    :listData="listData"
    :disabledDrag="false"
    :searchList="searchList"
    @on-list="onList">
    <Modal
      size="large"
      title="新增"
      :loading="true"
      @on-ok="onOk"
      ref="Modal"
      v-model="showModal">
      <ModalResources
        ref="ModalResources"
        :formItem="formItem"></ModalResources>
    </Modal>
   </TreeList>
</template>
<script>
import TreeList from '@/page/business/tree-list'
import Modal from '@/components/modal'
import searchList from './search-conf'
import operationList from './operation-conf'
import ModalResources from './modal/modalResources'
import {columns} from './table'
export default {
  data () {
    return {
      operationList: [],
      searchList: [],
      treeUrl: '.${extParam.REQUEST_PREFIX!}/${module.name ? uncap_first}TreeList',
      listUrl: '.${extParam.REQUEST_PREFIX!}/${module.name ? uncap_first}',
      treeData: {},
      showModal: false,
      treeMap: {
        id: '${module.pkField.name}'
      },
      listData: {},
      formItem: {}
    }
  },
  components: {
    TreeList,
    Modal,
    ModalResources
  },
  provide () {
    return {
      changeEdit: this.changeEdit,
      /*拖拽排序, disabledDrag为true时生效*/
      setSortIndex: this.setSortIndex,
      /*表格扩展*/
      expandParent: this.expandParent,
      /*过滤编辑按钮*/
      filterEdit: this.filterEdit,
      /*过滤删除按钮*/
      filterDelete: this.filterDelete,
      /*断言删除*/
      assertDelete: this.assertDelete
    }
  },
  created () {
    this.searchList = searchList.call(this)
    this.operationList = operationList.call(this)
    this.columns = columns
  },
  methods: {
    dropChange () {},
    add () {
      this.showModal = true
    },
    onList () {
      /*获取列表数据*/
    },
    setSortIndex () {
      this.$refs.treeList.forceRender()
    },
    expandParent () {
      /*调取列表刷新方法*/
      this.$refs.treeList.forceRender()
    },
    /*断言删除*/
    assertDelete () {
      return new Promise((resolve, reject) => {
        resolve(/*传入删除参数*/)
      })
    },
    /*过滤删除*/
    filterDelete () {
      return true
    },
    /*过滤编辑*/
    filterEdit () {
      return true
    },
    onOk () {
      let $refs = this.$refs
      $refs.ModalResources.validateFrom().then((res) => {
        if (!res) return
        $refs.Modal.close()
      })
    }
  }
}
</script>
<style lang="scss" scoped>

</style>
